package com.gzp.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance;

import com.gzp.pojo.UserAddress;
import com.gzp.service.UserService;

/**
 * springBoot使用注解org.apache.dubbo.config.annotation.Service 将服务暴露出去
 * 集群下负载均衡配置：四种算法都实现的LoadBalance这个接口，默认随机。 
 * 1、weight权重：权重越大，越容易被访问到。
 * 2、weight+loadbalance = "roundrobin"：按公约后的权重设置轮序比率。 
 * 3、loadbalance = "consistenthash"：一致性hash，相同参数的请求会一直访问同一提供者。
 * 
 * @author gzp
 *
 */
@Service(weight = 100, loadbalance = RoundRobinLoadBalance.NAME)
public class UserServiceImpl implements UserService {

	public static List<UserAddress> addressList = new ArrayList<UserAddress>();

	static {
		addressList.add(new UserAddress("1", "广东省深圳市罗湖区桂园路地王大厦5层505", "1"));
		addressList.add(new UserAddress("2", "广东省深圳市龙华区坂田街道风门坳东八巷1栋601", "2"));
	}

	public List<UserAddress> findAllAddress(String userId) {
		System.out.println("20890");
		return addressList;
	}

}
